package com.lh.service.impl;

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.lh.entity.table.*;
import com.lh.mapper.*;
import com.lh.utils.DateUtils;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.lh.service.IExcelService;
import com.lh.utils.Answer;
import com.lh.utils.LogUtil;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.io.FileUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;

@Service("excelService")
public class ExcelServiceImpl implements IExcelService {

	private LogUtil LOG = new LogUtil(ExcelServiceImpl.class);
	
	@Resource
    private ProblemSummaryInfoMapper problemSummaryInfoMapper;
	
	@Resource
    private TaskInfoMapper taskInfoMapper;
	
	@Resource
    private Task1InfoMapper task1InfoMapper;
	
	@Resource
    private Task2InfoMapper task2InfoMapper;

    @Resource
    private DeadlineNodeApprovalMapper deadlineNodeApprovalMapper;

	@Resource
    private RectificationInfoApprovalMapper rectificationInfoApprovalMapper;
	
	@Override
	public ResponseEntity<byte[]> downloadTaskTemplateExcel() {
		File excel;
		try {
			ClassPathResource pathResource = new ClassPathResource("template/taskTemplate.xlsx");
			excel = pathResource.getFile();
		} catch (Exception e) {
			LOG.out().error(e.getMessage(), e);
			return new ResponseEntity<byte[]>("读取模板文件异常".getBytes(Charset.forName("UTF-8")), HttpStatus.BAD_REQUEST);
		}
		HttpHeaders headers = new HttpHeaders();
		headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
		headers.add("Content-Disposition", "attachment; filename=taskTemplate.xlsx");
		return new ResponseEntity<byte[]>(FileUtil.readBytes(excel), headers, HttpStatus.OK);
	}

	@Override
	public Answer<String> uploadTaskExcel(MultipartFile file) {
        ExcelReader reader;
		try {
			reader = ExcelUtil.getReader(file.getInputStream());
		} catch (IOException e) {
			return LOG.error(Answer.build(), "读取上传的excel文件异常", e);
		}
        List<Map<String, Object>> ExcelList = reader.readAll();
        if (CollectionUtil.isEmpty(ExcelList)) {
            return Answer.error("Excel为空文件，请检查");
        }
        List<String> errorSummaryList = new ArrayList<>();
        Date date = new Date();
        for (int i = 0; i < ExcelList.size(); i ++) {
        	Map<String, Object> map = ExcelList.get(i);
            //项目名称	项目简介	建设地点	总投资额	牵头领导	牵头单位	责任人	行业/行业主管部门	项目进展及存在问题	备注 大类	中类	小类
            String title = Convert.toStr(map.get("项目名称"));
            String content = Convert.toStr(map.get("项目简介"));
            String areaName = Convert.toStr(map.get("建设地点"));
            String amount = Convert.toStr(map.get("总投资额"));
            String leadLeader = Convert.toStr(map.get("牵头领导"));
            String departmentName = Convert.toStr(map.get("牵头单位"));
            String personLiaible = Convert.toStr(map.get("责任人"));
            String sector = Convert.toStr(map.get("行业/行业主管部门"));
            String progressAndProblem = Convert.toStr(map.get("项目进展及存在问题"));
            String remark = Convert.toStr(map.get("备注"));
            String projectType = Convert.toStr(map.get("问题大类"));
            String projectChildType = Convert.toStr(map.get("问题类型"));
            String projectChildCategoryType = Convert.toStr(map.get("问题细分类型"));
            String creatorUnit = Convert.toStr(map.get("发起单位"));

            String petitioner = Convert.toStr(map.get("诉求人姓名"));
            if (StrUtil.isEmptyIfStr(content)){
                content = Convert.toStr(map.get("诉求内容"));
            }
            if (StrUtil.isEmptyIfStr(personLiaible)){
                personLiaible = Convert.toStr(map.get("包案责任人"));
            }
            if (StrUtil.isEmptyIfStr(departmentName)){
                departmentName = Convert.toStr(map.get("责任单位"));
            }

            String bjNo = Convert.toStr(map.get("办件编号"));
            String limitTime = Convert.toStr(map.get("办理时限"));
            String recordDate = Convert.toStr(map.get("上访登记日期"));
            String appealType = Convert.toStr(map.get("诉求分类"));
            String appealLevel = Convert.toStr(map.get("诉求分级"));
            String duration = Convert.toStr(map.get("积案年限"));
            String completionAttachments = Convert.toStr(map.get("办理进度"));

            String leaderContactName = Convert.toStr(map.get("牵头单位联系人"));
            String leaderContactPhone = Convert.toStr(map.get("牵头单位联系电话"));
            String creatorContactName = Convert.toStr(map.get("发起单位联系人"));
            String creatorContactPhone = Convert.toStr(map.get("发起单位联系电话"));

            String label = Convert.toStr(map.get("标签"));


            // 节点一信息
            String node1Name = Convert.toStr(map.get("节点一名称"));
            String node1Task = Convert.toStr(map.get("一目标任务"));
            if (StrUtil.isEmptyIfStr(node1Task)){
                node1Task = Convert.toStr(map.get("节点一要求"));
            }
            String node1Dept = Convert.toStr(map.get("一责任单位"));
            String node1Person = Convert.toStr(map.get("一责任人"));
            String node1TimeLimit = Convert.toStr(map.get("一要求完成时限"));
            String node1Time = Convert.toStr(map.get("一要求完成时间"));
            String node1Status = Convert.toStr(map.get("一状态"));
            String node1ActualTime = Convert.toStr(map.get("一实际完成时间"));
            String node1Problem = Convert.toStr(map.get("节点一存在问题"));

            // 节点二信息
            String node2Name = Convert.toStr(map.get("节点二名称"));
            String node2Task = Convert.toStr(map.get("二目标任务"));
            if (StrUtil.isEmptyIfStr(node2Task)){
                node2Task = Convert.toStr(map.get("节点二要求"));
            }
            String node2Dept = Convert.toStr(map.get("二责任单位"));
            String node2Person = Convert.toStr(map.get("二责任人"));
            String node2TimeLimit = Convert.toStr(map.get("二要求完成时限"));
            String node2Time = Convert.toStr(map.get("二要求完成时间"));
            String node2Status = Convert.toStr(map.get("二状态"));
            String node2ActualTime = Convert.toStr(map.get("二实际完成时间"));
            String node2Problem = Convert.toStr(map.get("节点二存在问题"));

            // 节点三信息
            String node3Name = Convert.toStr(map.get("节点三名称"));
            String node3Task = Convert.toStr(map.get("三目标任务"));
            if (StrUtil.isEmptyIfStr(node3Task)){
                node3Task = Convert.toStr(map.get("节点三要求"));
            }
            String node3Dept = Convert.toStr(map.get("三责任单位"));
            String node3Person = Convert.toStr(map.get("三责任人"));
            String node3TimeLimit = Convert.toStr(map.get("三要求完成时限"));
            String node3Time = Convert.toStr(map.get("三要求完成时间"));
            String node3Status = Convert.toStr(map.get("三状态"));
            String node3ActualTime = Convert.toStr(map.get("三实际完成时间"));
            String node3Problem = Convert.toStr(map.get("节点三存在问题"));

            // 节点四信息
            String node4Name = Convert.toStr(map.get("节点四名称"));
            String node4Task = Convert.toStr(map.get("四目标任务"));
            if (StrUtil.isEmptyIfStr(node4Task)){
                node4Task = Convert.toStr(map.get("节点四要求"));
            }
            String node4Dept = Convert.toStr(map.get("四责任单位"));
            String node4Person = Convert.toStr(map.get("四责任人"));
            String node4TimeLimit = Convert.toStr(map.get("四要求完成时限"));
            String node4Time = Convert.toStr(map.get("四要求完成时间"));
            String node4Status = Convert.toStr(map.get("四状态"));
            String node4ActualTime = Convert.toStr(map.get("四实际完成时间"));
            String node4Problem = Convert.toStr(map.get("节点四存在问题"));

            // 节点五信息
            String node5Name = Convert.toStr(map.get("节点五名称"));
            String node5Task = Convert.toStr(map.get("五目标任务"));
            String node5Dept = Convert.toStr(map.get("五责任单位"));
            String node5Person = Convert.toStr(map.get("五责任人"));
            String node5TimeLimit = Convert.toStr(map.get("五要求完成时限"));
            String node5Time = Convert.toStr(map.get("五要求完成时间"));
            String node5Status = Convert.toStr(map.get("五状态"));
            String node5ActualTime = Convert.toStr(map.get("五实际完成时间"));

            // 节点六信息
            String node6Name = Convert.toStr(map.get("节点六名称"));
            String node6Task = Convert.toStr(map.get("六目标任务"));
            String node6Dept = Convert.toStr(map.get("六责任单位"));
            String node6Person = Convert.toStr(map.get("六责任人"));
            String node6TimeLimit = Convert.toStr(map.get("六要求完成时限"));
            String node6Time = Convert.toStr(map.get("六要求完成时间"));
            String node6Status = Convert.toStr(map.get("六状态"));
            String node6ActualTime = Convert.toStr(map.get("六实际完成时间"));

            // 节点七信息
            String node7Name = Convert.toStr(map.get("节点七名称"));
            String node7Task = Convert.toStr(map.get("七目标任务"));
            String node7Dept = Convert.toStr(map.get("七责任单位"));
            String node7Person = Convert.toStr(map.get("七责任人"));
            String node7TimeLimit = Convert.toStr(map.get("七要求完成时限"));
            String node7Time = Convert.toStr(map.get("七要求完成时间"));
            String node7Status = Convert.toStr(map.get("七状态"));
            String node7ActualTime = Convert.toStr(map.get("七实际完成时间"));

            // 节点八信息
            String node8Name = Convert.toStr(map.get("节点八名称"));
            String node8Task = Convert.toStr(map.get("八目标任务"));
            String node8Dept = Convert.toStr(map.get("八责任单位"));
            String node8Person = Convert.toStr(map.get("八责任人"));
            String node8TimeLimit = Convert.toStr(map.get("八要求完成时限"));
            String node8Time = Convert.toStr(map.get("八要求完成时间"));
            String node8Status = Convert.toStr(map.get("八状态"));
            String node8ActualTime = Convert.toStr(map.get("八实际完成时间"));

            // 节点九信息
            String node9Name = Convert.toStr(map.get("节点九名称"));
            String node9Task = Convert.toStr(map.get("九目标任务"));
            String node9Dept = Convert.toStr(map.get("九责任单位"));
            String node9Person = Convert.toStr(map.get("九责任人"));
            String node9TimeLimit = Convert.toStr(map.get("九要求完成时限"));
            String node9Time = Convert.toStr(map.get("九要求完成时间"));
            String node9Status = Convert.toStr(map.get("九状态"));
            String node9ActualTime = Convert.toStr(map.get("九实际完成时间"));

            // 节点十信息
            String node10Name = Convert.toStr(map.get("节点十名称"));
            String node10Task = Convert.toStr(map.get("十目标任务"));
            String node10Dept = Convert.toStr(map.get("十责任单位"));
            String node10Person = Convert.toStr(map.get("十责任人"));
            String node10TimeLimit = Convert.toStr(map.get("十要求完成时限"));
            String node10Time = Convert.toStr(map.get("十要求完成时间"));
            String node10Status = Convert.toStr(map.get("十状态"));
            String node10ActualTime = Convert.toStr(map.get("十实际完成时间"));


            Task2Info task2Info = new Task2Info();
            task2Info.setTask1Id(45);
            task2Info.setContent(content);
            task2Info.setName(title);
            task2Info.setCreateTime(date);
            task2Info.setSort(99);
            task2InfoMapper.insert(task2Info);
            //rectificationInfo
            RectificationInfoApproval rectificationInfo = new RectificationInfoApproval();
            rectificationInfo.setSummaryId(45);
            rectificationInfo.setTitle(title);
            rectificationInfo.setContent(content);
            rectificationInfo.setState("新增申请待审核");
            rectificationInfo.setApprovalState("0");


            rectificationInfo.setDepartmentName(departmentName);
            rectificationInfo.setPersonLiaible(personLiaible);
            rectificationInfo.setLeadLeader(leadLeader);
            rectificationInfo.setProgressAndProblem(progressAndProblem);
            rectificationInfo.setRemark(remark);
            rectificationInfo.setProjectType(projectType);
            rectificationInfo.setProjectChildType(projectChildType);
            rectificationInfo.setProjectChildCategoryType(projectChildCategoryType);
            rectificationInfo.setSector(sector);
            rectificationInfo.setAmount(amount);
            rectificationInfo.setCreatorUnit(creatorUnit);
            rectificationInfo.setAreaName(areaName);
            rectificationInfo.setLabel(label);
            rectificationInfo.setCheckRemark("市政府督查室");
            rectificationInfo.setPetitioner(petitioner);

            rectificationInfo.setBjNo(bjNo);
            rectificationInfo.setLimitTime(limitTime);
            rectificationInfo.setRecordDate(recordDate);
            rectificationInfo.setAppealType(appealType);
            rectificationInfo.setAppealLevel(appealLevel);
            rectificationInfo.setDuration(duration);
            rectificationInfo.setCompletionAttachments(completionAttachments);
            rectificationInfo.setLeaderContactName(leaderContactName);
            rectificationInfo.setLeaderContactPhone(leaderContactPhone);
            rectificationInfo.setCreatorContactName(creatorContactName);
            rectificationInfo.setCreatorContactPhone(creatorContactPhone);
            if (StrUtil.isEmptyIfStr(title) && StrUtil.isNotBlank(bjNo)){
                rectificationInfo.setTitle(bjNo);
            }
            rectificationInfo.setTask2Id(task2Info.getId());
            rectificationInfo.setSort(99);
            rectificationInfoApprovalMapper.insert(rectificationInfo);

            Integer rectificationId = rectificationInfo.getId();
            rectificationInfo.setRectificationId(rectificationId);
            rectificationInfoApprovalMapper.updateById(rectificationInfo);
            System.out.println("== rectificationId : "+rectificationId);
            List<DeadlineNodeApproval> deadlineNodes = new ArrayList<>();
            if (StrUtil.isNotBlank(node1Name) &&
                    StrUtil.isNotBlank(node1Time) &&
                    !node1Time.equals("/")
            ){
                DeadlineNodeApproval deadlineNode1 = new DeadlineNodeApproval();
                deadlineNode1.setMainId(rectificationId);//mainId
                //2025.2.18 转date
                deadlineNode1.setDeadline(DateUtils.parseToDate(node1Time));
                deadlineNode1.setSort(1);
                deadlineNode1.setCreateTime(new Date());
                deadlineNode1.setName(node1Name);
                deadlineNode1.setDescription(node1Person);
                deadlineNode1.setRemark(node1Problem);
                deadlineNode1.setContent(node1Task);
                deadlineNode1.setDepartmentName(node1Dept);
                deadlineNode1.setTypeName("整改");
                deadlineNode1.setIsEnd(StrUtil.isNotBlank(node1ActualTime)?"1":"0");
                deadlineNode1.setProgress(node1Status);
                deadlineNode1.setEndTime(DateUtils.parseToDate(node1ActualTime));
                deadlineNode1.setWarnLevel("0");
                deadlineNode1.setRectificationId(rectificationId);
                deadlineNode1.setDeadlineType(node1TimeLimit);
                deadlineNode1.setState("1");
                deadlineNodes.add(deadlineNode1);
            }
            // 节点二
            if (StrUtil.isNotBlank(node2Name)&&
                    StrUtil.isNotBlank(node2Time) &&
                    !node2Time.equals("/")){
                DeadlineNodeApproval deadlineNode2 = new DeadlineNodeApproval();
                deadlineNode2.setMainId(rectificationId);
                deadlineNode2.setDeadline(DateUtils.parseToDate(node2Time));
                deadlineNode2.setSort(2);
                deadlineNode2.setCreateTime(new Date());
                deadlineNode2.setName(node2Name);
                deadlineNode2.setDescription(node2Person);
                deadlineNode2.setRemark(node2Problem);
                deadlineNode2.setContent(node2Task);
                deadlineNode2.setDepartmentName(node2Dept);
                deadlineNode2.setTypeName("整改");
                deadlineNode2.setIsEnd(StrUtil.isNotBlank(node2ActualTime)?"1":"0");
                deadlineNode2.setProgress(node2Status);
                deadlineNode2.setEndTime(DateUtils.parseToDate(node2ActualTime));
                deadlineNode2.setWarnLevel("0");
                deadlineNode2.setRectificationId(rectificationId);
                deadlineNode2.setDeadlineType(node2TimeLimit);
                deadlineNode2.setState("1");
                deadlineNodes.add(deadlineNode2);
            }

// 节点三
            if (StrUtil.isNotBlank(node3Name)&&
                    StrUtil.isNotBlank(node3Time) &&
                    !node3Time.equals("/")){
                DeadlineNodeApproval deadlineNode3 = new DeadlineNodeApproval();
                deadlineNode3.setMainId(rectificationId);
                deadlineNode3.setDeadline(DateUtils.parseToDate(node3Time));
                deadlineNode3.setSort(3);
                deadlineNode3.setCreateTime(new Date());
                deadlineNode3.setName(node3Name);
                deadlineNode3.setDescription(node3Person);
                deadlineNode3.setRemark(node3Problem);
                deadlineNode3.setContent(node3Task);
                deadlineNode3.setDepartmentName(node3Dept);
                deadlineNode3.setTypeName("整改");
                deadlineNode3.setIsEnd(StrUtil.isNotBlank(node3ActualTime)?"1":"0");
                deadlineNode3.setProgress(node3Status);
                deadlineNode3.setEndTime(DateUtils.parseToDate(node3ActualTime));
                deadlineNode3.setWarnLevel("0");
                deadlineNode3.setRectificationId(rectificationId);
                deadlineNode3.setDeadlineType(node3TimeLimit);
                deadlineNode3.setState("1");
                deadlineNodes.add(deadlineNode3);
            }
// 节点四
            if (StrUtil.isNotBlank(node4Name)&&
                    StrUtil.isNotBlank(node4Time) &&
                    !node4Time.equals("/")){
                DeadlineNodeApproval deadlineNode4 = new DeadlineNodeApproval();
                deadlineNode4.setMainId(rectificationId);
                deadlineNode4.setDeadline(DateUtils.parseToDate(node4Time));
                deadlineNode4.setSort(4);
                deadlineNode4.setCreateTime(new Date());
                deadlineNode4.setName(node4Name);
                deadlineNode4.setRemark(node4Problem);
                deadlineNode4.setDescription(node4Person);
                deadlineNode4.setContent(node4Task);
                deadlineNode4.setDepartmentName(node4Dept);
                deadlineNode4.setTypeName("整改");
                deadlineNode4.setIsEnd(StrUtil.isNotBlank(node4ActualTime)?"1":"0");
                deadlineNode4.setProgress(node4Status);
                deadlineNode4.setEndTime(DateUtils.parseToDate(node4ActualTime));
                deadlineNode4.setWarnLevel("0");
                deadlineNode4.setRectificationId(rectificationId);
                deadlineNode4.setDeadlineType(node4TimeLimit);
                deadlineNode4.setState("1");
                deadlineNodes.add(deadlineNode4);
            }

// 节点五
            if (StrUtil.isNotBlank(node5Name)&&
                    StrUtil.isNotBlank(node5Time) &&
                    !node5Time.equals("/")){
                DeadlineNodeApproval deadlineNode5 = new DeadlineNodeApproval();
                deadlineNode5.setMainId(rectificationId);
                deadlineNode5.setDeadline(DateUtils.parseToDate(node5Time));
                deadlineNode5.setSort(5);
                deadlineNode5.setCreateTime(new Date());
                deadlineNode5.setName(node5Name);
                deadlineNode5.setDescription(node5Person);
                deadlineNode5.setContent(node5Task);
                deadlineNode5.setDepartmentName(node5Dept);
                deadlineNode5.setTypeName("整改");
                deadlineNode5.setIsEnd(StrUtil.isNotBlank(node5ActualTime)?"1":"0");
                deadlineNode5.setProgress(node5Status);
                deadlineNode5.setEndTime(DateUtils.parseToDate(node5ActualTime));
                deadlineNode5.setWarnLevel("0");
                deadlineNode5.setRectificationId(rectificationId);
                deadlineNode5.setDeadlineType(node5TimeLimit);
                deadlineNode5.setState("1");
                deadlineNodes.add(deadlineNode5);
            }

// 节点六
            if (StrUtil.isNotBlank(node6Name)&&
                    StrUtil.isNotBlank(node6Time) &&
                    !node6Time.equals("/")){
                DeadlineNodeApproval deadlineNode6 = new DeadlineNodeApproval();
                deadlineNode6.setMainId(rectificationId);
                deadlineNode6.setDeadline(DateUtils.parseToDate(node6Time));
                deadlineNode6.setSort(6);
                deadlineNode6.setCreateTime(new Date());
                deadlineNode6.setName(node6Name);
                deadlineNode6.setDescription(node6Person);
                deadlineNode6.setContent(node6Task);
                deadlineNode6.setDepartmentName(node6Dept);
                deadlineNode6.setTypeName("整改");
                deadlineNode6.setIsEnd(StrUtil.isNotBlank(node6ActualTime)?"1":"0");
                deadlineNode6.setProgress(node6Status);
                deadlineNode6.setEndTime(DateUtils.parseToDate(node6ActualTime));
                deadlineNode6.setWarnLevel("0");
                deadlineNode6.setRectificationId(rectificationId);
                deadlineNode6.setDeadlineType(node6TimeLimit);
                deadlineNode6.setState("1");
                deadlineNodes.add(deadlineNode6);
            }

// 节点七
            if (StrUtil.isNotBlank(node7Name)&&
                    StrUtil.isNotBlank(node7Time) &&
                    !node7Time.equals("/")){
                DeadlineNodeApproval deadlineNode7 = new DeadlineNodeApproval();
                deadlineNode7.setMainId(rectificationId);
                deadlineNode7.setDeadline(DateUtils.parseToDate(node7Time));
                deadlineNode7.setSort(7);
                deadlineNode7.setCreateTime(new Date());
                deadlineNode7.setName(node7Name);
                deadlineNode7.setDescription(node7Person);
                deadlineNode7.setContent(node7Task);
                deadlineNode7.setDepartmentName(node7Dept);
                deadlineNode7.setTypeName("整改");
                deadlineNode7.setIsEnd(StrUtil.isNotBlank(node7ActualTime)?"1":"0");
                deadlineNode7.setProgress(node7Status);
                deadlineNode7.setEndTime(DateUtils.parseToDate(node7ActualTime));
                deadlineNode7.setWarnLevel("0");
                deadlineNode7.setRectificationId(rectificationId);
                deadlineNode7.setDeadlineType(node7TimeLimit);
                deadlineNode7.setState("1");
                deadlineNodes.add(deadlineNode7);
            }

// 节点八
            if (StrUtil.isNotBlank(node8Name)&&
                    StrUtil.isNotBlank(node8Time) &&
                    !node8Time.equals("/")){
                DeadlineNodeApproval deadlineNode8 = new DeadlineNodeApproval();
                deadlineNode8.setMainId(rectificationId);
                deadlineNode8.setDeadline(DateUtils.parseToDate(node8Time));
                deadlineNode8.setSort(8);
                deadlineNode8.setCreateTime(new Date());
                deadlineNode8.setName(node8Name);
                deadlineNode8.setDescription(node8Person);
                deadlineNode8.setContent(node8Task);
                deadlineNode8.setDepartmentName(node8Dept);
                deadlineNode8.setTypeName("整改");
                deadlineNode8.setIsEnd(StrUtil.isNotBlank(node8ActualTime)?"1":"0");
                deadlineNode8.setProgress(node8Status);
                deadlineNode8.setEndTime(DateUtils.parseToDate(node8ActualTime));
                deadlineNode8.setWarnLevel("0");
                deadlineNode8.setRectificationId(rectificationId);
                deadlineNode8.setDeadlineType(node8TimeLimit);
                deadlineNode8.setState("1");
                deadlineNodes.add(deadlineNode8);
            }

// 节点九
            if (StrUtil.isNotBlank(node9Name)&&
                    StrUtil.isNotBlank(node9Time) &&
                    !node9Time.equals("/")){
                DeadlineNodeApproval deadlineNode9 = new DeadlineNodeApproval();
                deadlineNode9.setMainId(rectificationId);
                deadlineNode9.setDeadline(DateUtils.parseToDate(node9Time));
                deadlineNode9.setSort(9);
                deadlineNode9.setCreateTime(new Date());
                deadlineNode9.setName(node9Name);
                deadlineNode9.setDescription(node9Person);
                deadlineNode9.setContent(node9Task);
                deadlineNode9.setDepartmentName(node9Dept);
                deadlineNode9.setTypeName("整改");
                deadlineNode9.setIsEnd(StrUtil.isNotBlank(node9ActualTime)?"1":"0");
                deadlineNode9.setProgress(node9Status);
                deadlineNode9.setEndTime(DateUtils.parseToDate(node9ActualTime));
                deadlineNode9.setWarnLevel("0");
                deadlineNode9.setRectificationId(rectificationId);
                deadlineNode9.setDeadlineType(node9TimeLimit);
                deadlineNode9.setState("1");
                deadlineNodes.add(deadlineNode9);
            }

// 节点十
            if (StrUtil.isNotBlank(node10Name)&&
                    StrUtil.isNotBlank(node10Time) &&
                    !node10Time.equals("/")){
                DeadlineNodeApproval deadlineNode10 = new DeadlineNodeApproval();
                deadlineNode10.setMainId(rectificationId);
                deadlineNode10.setDeadline(DateUtils.parseToDate(node10Time));
                deadlineNode10.setSort(10);
                deadlineNode10.setCreateTime(new Date());
                deadlineNode10.setName(node10Name);
                deadlineNode10.setDescription(node10Person);
                deadlineNode10.setContent(node10Task);
                deadlineNode10.setDepartmentName(node10Dept);
                deadlineNode10.setTypeName("整改");
                deadlineNode10.setIsEnd(StrUtil.isNotBlank(node10ActualTime)?"1":"0");
                deadlineNode10.setProgress(node10Status);
                deadlineNode10.setEndTime(DateUtils.parseToDate(node10ActualTime));
                deadlineNode10.setWarnLevel("0");
                deadlineNode10.setRectificationId(rectificationId);
                deadlineNode10.setDeadlineType(node10TimeLimit);
                deadlineNode10.setState("1");
                deadlineNodes.add(deadlineNode10);
            }
            deadlineNodeApprovalMapper.batchInsertByAnnotation(deadlineNodes);
        }
        if(errorSummaryList.size() > 0) {
        	return Answer.error("导入完毕，部分事项存在错误且未导入，请检查：" + String.join("、", errorSummaryList));
        }
        return Answer.ok("导入成功");
        
	}

}
